//
//  ViewOfInput.m
//  气泡聊天Demo
//
//  Created by 米华 on 16/7/11.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "ViewOfInput.h"
#import "Masonry.h"
@implementation ViewOfInput

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self createSubviews];
        
    }
    return self;
}

#pragma mark - 创建子控件
- (void)createSubviews {
    
    self.buttonOfVoice = [UIButton buttonWithType:UIButtonTypeCustom];
    
    self.buttonOfVoice.layer.cornerRadius = 15;
    
    self.buttonOfVoice.backgroundColor = [UIColor colorWithRed:0.62 green:0.84 blue:0.98 alpha:1.00];
    
    self.buttonOfVoice.titleLabel.font = [UIFont systemFontOfSize:12];
    
    [self.buttonOfVoice setTitle:@"语音" forState:UIControlStateNormal];
    
    [self addSubview:self.buttonOfVoice];
    
    
    
    self.textView = [[UITextView alloc] init];
    
    self.textView.layer.cornerRadius = 10;
    
    self.textView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    
    self.textView.backgroundColor = [UIColor whiteColor];
    
    self.textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    
    self.textView.returnKeyType = UIReturnKeySend;
    
    
    
    [self addSubview:self.textView];
    
    
    self.buttonOfSend = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [self.buttonOfSend setTitle:@"发送" forState:UIControlStateNormal];
    
    self.buttonOfSend.backgroundColor = [UIColor colorWithRed:0.24 green:0.76 blue:0.67 alpha:1.00];
    
    self.buttonOfSend.titleLabel.font = [UIFont systemFontOfSize:12];
    
    self.buttonOfSend.layer.borderColor = [UIColor lightGrayColor].CGColor;
    
    self.buttonOfSend.layer.cornerRadius = 8;
    
    [self addSubview:self.buttonOfSend];
    
    
}

#pragma mark - 子控件布局
- (void)layoutSubviews {
    
    
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.offset(-10);
        
        make.height.offset(self.frame.size.height - 20);
    
    }];
    
    
    [self.buttonOfVoice mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.leading.offset(5);
        
        make.right.equalTo(self.textView.mas_left).offset(-5);
        
        make.bottom.offset(-10);
        
        make.width.offset(30);
        
        make.height.offset(30);
        
    }];
    
    
    [self.buttonOfSend mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.textView.mas_right).offset(5);
        
        make.trailing.offset(-5);
        
        make.bottom.offset(-10);
        
        make.width.offset(50);
        
        make.height.offset(30);
        
    }];
    
}


@end
